package com.sky.controller.admin;

import com.sky.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@RequestMapping("/admin/shop")
@Api(tags = "店铺营业设置")
public class ShopController {

    @Autowired
    RedisTemplate redisTemplate;

    @GetMapping("/status")
    public Result status() {
        Integer status=Integer.valueOf(redisTemplate.opsForValue().get("shop-status").toString());
        return Result.success(status);
    }

    @PutMapping("/{status}")
    @ApiOperation("设置营业状态")
    public Result updateStatus(@PathVariable Integer status) {
        redisTemplate.opsForValue().set("shop-status",status);
        return Result.success();
    }
}
